from django.shortcuts import render
from rest_framework.response import Response
from apps.users.models import User
from datetime import date
from rest_framework.views import APIView
from rest_framework.generics import GenericAPIView

class DailyActiveCountAPIView(APIView):

    def get(self,request):

        today = date.today()
        count = User.objects.filter(last_login__gte=today).count()

        return Response({'count':count})

class DailyOrderCountAPIView(GenericAPIView):

    def get(self,request):

        today = date.today()
        count = User.objects.filter(orderinfo__create_time__gte=today).count()

        return Response({'count':count})

class DailyIncrementCountAPIView(APIView):

    def get(self,request):

        today = date.today()
        count = User.objects.filter(date_joined__gte=today).count()

        return Response({'count':count})


class DailyTotalCountAPIView(APIView):

    def get(self,request):

        count = User.objects.all().count()

        return Response({'count':count})